package com.qianfeng.propertygroup.dao;

import com.qianfeng.propertygroup.pojo.Publicboard;
import com.qianfeng.propertygroup.vo.PublicboardVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * @author LiXuekai on 2020/12/22
 */

public interface PublicboardDao {
    @Insert("INSERT INTO publicboard(date,userid,content,status,click,image,judge,dstatus) VALUES(#{date},#{userid},#{content},#{status},#{click},#{image},#{judge},#{dstatus})")
    void addPublicboard(Publicboard publicboard);

    @Update("UPDATE publicboard SET date=#{date},userid=#{userid},content=#{content},status=#{status},click=#{click},image=#{image},judge=#{judge},dstatus=#{dstatus} WHERE id=#{id}")
    void updatePublicboard(Publicboard publicboard);

    @Update("UPDATE publicboard SET dstatus=1 WHERE id=#{id}")
    void deletePublicboard(Long id);

    @Select("SELECT p.id id,p.date date,p.userid userid,p.content content,p.status status,p.click click,p.image image,p.judge judge,u.username username FROM publicboard p LEFT JOIN user u ON p.userid = u.id WHERE p.dstatus=0 ")
    List<PublicboardVo> getAllPublicboard();

    @Select("select date,userid,content,status,click,image,judge from table where date = #{date1}")
    List<Publicboard> getPublicboardBuDates(@Param("date1")Date date1);

}
